import os
import sys

# WSGI applications are not allowed to write to stdout,
# so redirect it to stderr which writes to the webserver error log
sys.stdout = sys.stderr

PROJECT_PATH = os.path.dirname(__file__)
sys.path.append(PROJECT_PATH)

import locate_mypyutils
from mypyutils import virtualenv

execfile(virtualenv.get_activate_script_path())
# Set back sys.prefix to not effect other python instances
# See http://code.google.com/p/modwsgi/wiki/VirtualEnvironments
sys.prefix = sys.real_prefix

os.environ['DJANGO_SETTINGS_MODULE'] = '$project_name$.settings'
#os.environ['PYTHON_EGG_CACHE'] = os.path.join(os.path.dirname(PROJECT_PATH), 'egg-cache')

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()